<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise</title>
</head>
<body>
    <script>
        console.log("开始");
        console.log("运行中");
        let flag = false;
        let promise = new Promise(function(resolve,reject){
            console.log("异步执行的代码");
            if(flag){
                resolve();
            }else{
                reject();
            }
        });
        promise.then(function(){
            console.log("异步执行代码成功");
        },function(){
            console.log("异步执行代码失败");
        });
        console.log("结束");
    </script>
</body>
</html>